local rolely_baojun = fk.CreateSkill {
    name = "rolely_baojun",
    tags = { Skill.Compulsory }
}
Fk:loadTranslationTable {
    ["rolely_baojun"] = "暴军",
    [":rolely_baojun"] = "锁定技，每回合各限一次，当你受到其他角色造成的伤害后，或对其他角色造成伤害后，你与其各自展示各自手牌中任意张花色不同的手牌，因此展示较多者对另一方造成一点伤害，若相等，弃置这些牌。",

    ["$rolely_baojun1"] = "雷声轰鸣，可击千军！",
    ["$rolely_baojun2"] = "迅雷烈风，威力无边！",
}
Fk:addPoxiMethod {
    name = "rolely_baojun",
    prompt = "暴军：请选择展示任意张花色不同的牌",
    card_filter = function(to_select, selected, data)
        if #selected == 0 then
            return Fk:getCardById(to_select).suit ~= Card.NoSuit
        else
            return table.every(selected, function(id)
                return Fk:getCardById(to_select):compareSuitWith(Fk:getCardById(id), true)
            end)
        end
    end,
    feasible = function(selected)
        return #selected > 0
    end,
    default_choice = function(data, extra_data)
        return { data[1][2][1] }
    end,
}
rolely_baojun:addEffect(fk.Damage, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(rolely_baojun.name) and data.to ~= player and
            data.to:getHandcardNum() > 0 and player:getHandcardNum() > 0 and
            player:getMark("rolely_baojun_damage-turn") == 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, "rolely_baojun_damage-turn", 1)
        local cards1 = room:askToPoxi(player, {
            poxi_type = rolely_baojun.name,
            data = {
                { rolely_baojun.name, player:getCardIds("h") },
            },
            cancelable = false,
        })
        local cards2 = room:askToPoxi(data.to, {
            poxi_type = rolely_baojun.name,
            data = {
                { rolely_baojun.name, data.to:getCardIds("h") },
            },
            cancelable = false,
        })
        player:showCards(cards1)
        data.to:showCards(cards2)
        room:delay(1200)
        if #cards1 == #cards2 then
            room:throwCard(cards1, rolely_baojun.name, player, player)
            room:throwCard(cards2, rolely_baojun.name, data.to, data.to)
        end
        if #cards1 > #cards2 then
            room:damage({
                from = player,
                to = data.to,
                damage = 1,
                damageType = fk.NormalDamage,
                skillName = rolely_baojun.name
            })
        elseif #cards1 < #cards2 then
            room:damage({
                from = data.to,
                to = player,
                damage = 1,
                damageType = fk.NormalDamage,
                skillName = rolely_baojun.name
            })
        end
    end,
})

rolely_baojun:addEffect(fk.Damaged, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(rolely_baojun.name) and data.from and data.from ~= player and
            data.from:getHandcardNum() > 0 and player:getHandcardNum() > 0 and
            player:getMark("rolely_baojun_damaged-turn") == 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player, "rolely_baojun_damaged-turn", 1)
        local cards1 = room:askToPoxi(player, {
            poxi_type = rolely_baojun.name,
            data = {
                { rolely_baojun.name, player:getCardIds("h") },
            },
            cancelable = false,
        })
        local cards2 = room:askToPoxi(data.from, {
            poxi_type = rolely_baojun.name,
            data = {
                { rolely_baojun.name, data.from:getCardIds("h") },
            },
            cancelable = false,
        })
        player:showCards(cards1)
        data.from:showCards(cards2)
        room:delay(1200)
        if #cards1 == #cards2 then
            room:throwCard(cards1, rolely_baojun.name, player, player)
            room:throwCard(cards2, rolely_baojun.name, data.from, data.from)
        end
        if #cards1 > #cards2 then
            room:damage({
                from = player,
                to = data.from,
                damage = 1,
                damageType = fk.NormalDamage,
                skillName = rolely_baojun.name
            })
        elseif #cards1 < #cards2 then
            room:damage({
                from = data.from,
                to = player,
                damage = 1,
                damageType = fk.NormalDamage,
                skillName = rolely_baojun.name
            })
        end
    end,
})
return rolely_baojun
